/*
VERSION 1.0
9/19/06
Michael Trezza
LITHYEMindustries, llc.
*/

import MovieClipLoader;
import mx.events.EventDispatcher;
class com.Lithyem.LoaderQueue extends Object{
	
	var queue:Array;
	var MCL:MovieClipLoader;
	
	var addEventListener:Function;
	var removeEventListener:Function;
	var dispatchEvent:Function;
	
	function LoaderQueue(){
		queue = new Array();
		mx.events.EventDispatcher.initialize(this);
		MCL = new MovieClipLoader();
		MCL.addListener(this);
	}
	
	function onLoadComplete():Void{
		//trace("cliploaded");
		loadNext();
	}
	
	function addClip(f:String,o:Object):Void{
		//trace(f + " : " + o._name);
		queue.push({file:f,clip:o});
	}
	
	function loadAll():Void{
		loadNext();
	}
	
	function loadNext(){
		var l = queue.length;
		if(l > 0){
			var obj = queue.shift();
			MCL.loadClip(obj.file,obj.clip);
			//trace("load clip:" + obj.clip);
		}else{
			//trace("done");
			var evtObj:Object = {target:this,type:"onQueueComplete"};
			evtObj.message = "Success";
			dispatchEvent(evtObj);
		}
		
		
	}
}


/*

function onQueueComplete() {
	trace("done loading all");
}
var loaderQueue = new com.Lithyem.LoaderQueue();
loaderQueue.addEventListener("onQueueComplete", this);
loaderQueue.addClip("as400.jpg", blank_mc);
loaderQueue.addClip("as400.jpg", blank2_mc);
loaderQueue.addClip("as400.jpg", blank3_mc);
loaderQueue.addClip("as400.jpg", blank4_mc);
loaderQueue.addClip("as400.jpg", blank5_mc);
loaderQueue.loadAll();


dead_mc.disableStage();


*/